﻿$(function () {
    // luckysheet.destroy()
    luckysheet.create({
        container: 'luckysheet',
        lang: 'zh',
        title: titlename,
        myFolderUrl: return_url,
        allowEdit: true,
        forceCalculation: false,
        allowUpdate: true,
        updateImageUrl: "/markdown/uploadFileDiv/",
        updateUrl: "ws://" + window.location.hostname + ":" + window.location.port +"/job/ws/sheet/" + sheet_filename + "/",
        loadUrl: "/markdown/sheetEdit/",

        // gridKey loadUrl的提交参数
        gridKey: sheet_filename,
        functionButton:
            '<button id="saveData" type="button" onclick="saveRedisData();" class="btn btn-primary" style="padding:3px 6px;font-size: 12px;margin-right: 10px;">保存</button>'+
            '<button id="exportData" type="button" onclick="exportData();" class="btn btn-primary" style="padding:3px 6px;font-size: 12px;margin-right: 10px;">导出</button>'+
            '<a href="/markdown/sheet/viewDemo/">LuckysheetDemo</a>',
    });
});



function saveRedisData() {
    console.log('save redis data!');
    $.get(
        '/markdown/saveSheetData/?gridKey=' + sheet_filename,
        function (data){
            console.log(data);
            alert(data.res_info);
        }
    )
}

function exportData() {
    var sheetdata = luckysheet.getAllSheets();
    console.log(sheetdata);

    exportExcel(sheetdata, titlename);
}

